import axios from 'axios'
const service = axios.create({
  // 接口地址的前缀
  baseURL: ' http://localhost:34588/',
  // baseURL: "https://www.fastmock.site/mock/a109f987145b9bc2364e0b549359aa7b/imooc-data/api/",
  timeout: 5000
})

service.interceptors.response.use(
  (response) => {
    if (response.status === 200 && response.data) {
      const { data } = response
      return data
    } else {
      return Promise.reject(new Error('网络请求失败'))
    }
  },
  (error) => {
    console.error(error)
  }
)
export default service
